﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Windows.Controls.Ribbon;
using ChoDiaOc_HK_WPF.Views.KhachHang;
using ChoDiaOc_HK_WPF.Views.TiepNhanDangKy;
using ChoDiaOc_HK_WPF.Views.ChupAnh;
using ChoDiaOc_HK_WPF.Views;

namespace ChoDiaOc_HK_WPF.Views {
    /// <summary>
    /// Interaction logic for ManHinhTiepNhanDangKy.xaml
    /// </summary>
    public partial class ManHinhTiepNhanDangKy : RibbonWindow {

        private TiepNhanDangKy.BangGiaDichVu bangGiaDichVuControl = null;

        public TiepNhanDangKy.BangGiaDichVu BangGiaDichVuControl {
            get {
                if (bangGiaDichVuControl == null) {
                    bangGiaDichVuControl = new TiepNhanDangKy.BangGiaDichVu();
                } return bangGiaDichVuControl;
            }
        }

        private BangQuyDinh bangQuyDinhControl = null;

        public BangQuyDinh BangQuyDinhControl {
            get {
                if (bangQuyDinhControl == null) {
                    bangQuyDinhControl = new BangQuyDinh();
                } return bangQuyDinhControl;
            }
        }

        private DangKyDiaOc dangKyDiaOcControl = null;

        public DangKyDiaOc DangKyDiaOcControl {
            get {
                if (dangKyDiaOcControl == null) {
                    dangKyDiaOcControl = new DangKyDiaOc();
                } return dangKyDiaOcControl;
            }
        }

        private DangKyKhachHang dangKyKhachHangControl = null;

        public DangKyKhachHang DangKyKhachHangControl {
            get {
                if (dangKyKhachHangControl == null) {
                    dangKyKhachHangControl = new DangKyKhachHang();
                } return dangKyKhachHangControl;
            }
        }

        private DangKyQuangCao dangKyQuangCaoControl = null;

        public DangKyQuangCao DangKyQuangCaoControl {
            get {
                if (dangKyQuangCaoControl == null) {
                    dangKyQuangCaoControl = new DangKyQuangCao();
                } return dangKyQuangCaoControl;
            }
        }

        private KiemTraGiayTo kiemTraGiayToControl = null;

        public KiemTraGiayTo KiemTraGiayToControl {
            get {
                if (kiemTraGiayToControl == null) {
                    kiemTraGiayToControl = new KiemTraGiayTo();
                } return kiemTraGiayToControl;
            }
        }

        private LapPhieuThu lapPhieuThuControl = null;

        public LapPhieuThu LapPhieuThuControl {
            get {
                if (lapPhieuThuControl == null) {
                    lapPhieuThuControl = new LapPhieuThu();
                } return lapPhieuThuControl;
            }
        }

        private int step = 1;

        public int Step {
            get { return step; }
            set { step = value; }
        }


        public ManHinhTiepNhanDangKy() {
            InitializeComponent();

            // Insert code required on object creation below this point.

            App.ManHinhTiepNhanDangKy = this;
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
            e.Cancel = true;
            this.Hide();
            gridMain.Children.Clear();
            bangGiaDichVuControl = null;
            bangQuyDinhControl = null;
            dangKyDiaOcControl = null;
            dangKyKhachHangControl = null;
            dangKyQuangCaoControl = null;
            lapPhieuThuControl = null;
            step = 0;
            DoNextStep(0);
            gridMain.Children.Clear();
            gridMain.Children.Add(BangQuyDinhControl);
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            btnDangKyKhachHang.IsEnabled = true;
            btnDangKyDiaOc.IsEnabled = false;
            btnDangKyDichVu.IsEnabled = false;
            btnKiemTraGiayTo.IsEnabled = false;
            btnLapPhieuThu.IsEnabled = false;

            //gridMain.Children.Add(BangGiaDichVuControl);
            gridMain.Children.Add(DangKyKhachHangControl);
        }

        private void btnTroVeManHinhChinh_Click(object sender, RoutedEventArgs e) {
            if (MessageBoxResult.OK == MessageBox.Show("Thông tin đăng ký sẽ bị mất?", "Cảnh báo", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel, MessageBoxOptions.None)) {
                this.Close();
            }
        }

        private void btnBangGiaDV_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(BangGiaDichVuControl);
        }

        private void btnQuyDinhDV_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(BangQuyDinhControl);
        }

        private void btnDangKyKhachHang_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(DangKyKhachHangControl);
            //DoNextStep(1);
        }

        private void btnDangKyDiaOc_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(DangKyDiaOcControl);
            //DoNextStep(2);
        }

        private void btnDangKyDichVu_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(DangKyQuangCaoControl);
            //DoNextStep(3);
        }

        private void btnKiemTraGiayTo_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(KiemTraGiayToControl);
        }

        private void btnLapPhieuThu_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(LapPhieuThuControl);
        }

        public void DoNextStep(int position) {
            if (step == position) {
                step++;
            }
            switch (step) {
                case 1:
                    btnDangKyKhachHang.IsEnabled = true;
                    btnDangKyDiaOc.IsEnabled = false;
                    btnDangKyDichVu.IsEnabled = false;
                    btnKiemTraGiayTo.IsEnabled = false;
                    btnLapPhieuThu.IsEnabled = false;
                    gridMain.Children.Clear();
                    gridMain.Children.Add(DangKyKhachHangControl);
                    break;
                case 2:
                    btnDangKyKhachHang.IsEnabled = true;
                    btnDangKyDiaOc.IsEnabled = true;
                    btnDangKyDichVu.IsEnabled = false;
                    btnKiemTraGiayTo.IsEnabled = false;
                    btnLapPhieuThu.IsEnabled = false;
                    gridMain.Children.Clear();
                    gridMain.Children.Add(DangKyDiaOcControl);
                    break;
                case 3:
                    btnDangKyKhachHang.IsEnabled = true;
                    btnDangKyDiaOc.IsEnabled = true;
                    btnDangKyDichVu.IsEnabled = true;
                    btnKiemTraGiayTo.IsEnabled = false;
                    btnLapPhieuThu.IsEnabled = false;
                    gridMain.Children.Clear();
                    gridMain.Children.Add(DangKyQuangCaoControl);
                    break;
                case 4:
                    btnDangKyKhachHang.IsEnabled = true;
                    btnDangKyDiaOc.IsEnabled = true;
                    btnDangKyDichVu.IsEnabled = true;
                    btnKiemTraGiayTo.IsEnabled = true;
                    btnLapPhieuThu.IsEnabled = false;
                    gridMain.Children.Clear();
                    gridMain.Children.Add(KiemTraGiayToControl);
                    break;
                case 5:
                    btnDangKyKhachHang.IsEnabled = true;
                    btnDangKyDiaOc.IsEnabled = true;
                    btnDangKyDichVu.IsEnabled = true;
                    btnKiemTraGiayTo.IsEnabled = true;
                    btnLapPhieuThu.IsEnabled = true;
                    gridMain.Children.Clear();
                    gridMain.Children.Add(LapPhieuThuControl);
                    break;
            }
        }

        public void btnNhapTiep_Click(object sender, RoutedEventArgs e) {
            if (step > 1) {
                step = 1;
                DoNextStep(1);
                gridMain.Children.Clear();
                dangKyDiaOcControl = null;
                dangKyQuangCaoControl = null;
                lapPhieuThuControl = null;
                gridMain.Children.Add(BangGiaDichVuControl);
            }
        }


    }
}
